package com.struts2.student.action;

import java.util.List;

import com.strust2.action.BaseAction;
import com.struts2.student.entity.Classes;
import com.struts2.student.entity.Major;
import com.struts2.student.service.ClassesService;
import com.struts2.student.service.ClassesServiceImpl;
import com.struts2.student.service.MajorService;
import com.struts2.student.service.MajorServiceImpl;

import HttpUtil.HttpUtil;

public class ClassesAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private Integer classId;
	private String className;
	private Integer majorId;

	public String findClasses(){
		ClassesService classesService = new ClassesServiceImpl();
		List<Classes> classesList = classesService.findClasses();
		
		MajorService majorService = new MajorServiceImpl();
		List<Major> majorList = majorService.findMajor();
		
		HttpUtil.setAttribute("classesList",classesList,"majorList",majorList);
		return SUCCESS;
	}
	/**
	 * 根据id获取班级信息
	 * @author Administrator
	 * @date  2017年8月29日 上午12:01:44
	 * @version v1.0
	 * @return
	 */
	public String getClassesById(){
		ClassesService classesService = new ClassesServiceImpl();
		Classes classes = classesService.getClassesById(classId);
		
		ajaxMap.put("classId", classes.getClassId());
		ajaxMap.put("className", classes.getClassName());
		ajaxMap.put("majorId", classes.getMajor().getMajorId());
		return SUCCESS;
	}
	
	public Integer getClassesId() {
		return classId;
	}
	public void setClassesId(Integer classesId) {
		this.classId = classesId;
	}
	public String getClassesName() {
		return className;
	}
	public void setClassesName(String classesName) {
		this.className = classesName;
	}
	public Integer getMajorId() {
		return majorId;
	}
	public void setMajorId(Integer majorId) {
		this.majorId = majorId;
	}
	
}
